home *** CD-ROM | disk | FTP | other *** search
/ Champak 86 / (Vol 86) My Disc.iso / Games / pet_1112.swf / scripts / DefineSprite_451 / frame_22 / DoAction.as
Text File  |  2009-04-14  |  8KB  |  298 lines

  1. function getUnusedRandom(array)
  2. {
  3.    return array.splice(random(array.length),1)[0];
  4. }
  5. function scoreMatch()
  6. {
  7.    matches++;
  8.    scoreBoard_mc["matchBubble" + matches]._alpha = 100;
  9.    scoreBoard_mc["matchBubble" + matches].text_txt.text = matches;
  10.    scoreBoard_mc["matchBubble" + matches].whiteIn(0.05);
  11.    if(nextMatchNum == -1)
  12.    {
  13.       nextMatchNum = getUnusedRandom(unusedRandoms);
  14.    }
  15.    gameTimeouts[8] = setTimeout(nextMatch,1000);
  16.    magenta.barkRandom();
  17.    randomEars();
  18. }
  19. function nextMatch()
  20. {
  21.    if(matches != 0 && doors_mc._currentframe != 1)
  22.    {
  23.       doors_mc.gotoAndPlay("close");
  24.    }
  25.    gameTimeouts[0] = setTimeout(function()
  26.    {
  27.       for(var _loc1_ in ezClick2Drags)
  28.       {
  29.          removeClip(ezClick2Drags[_loc1_]);
  30.       }
  31.       delete ezClick2Drags;
  32.       magenta.removeClothes("all");
  33.    }
  34.    ,3400);
  35.    gameTimeouts[1] = setTimeout(function()
  36.    {
  37.       trace("Next match: " + nextMatchNum);
  38.       gotoAndStop("match" + nextMatchNum);
  39.       if(nextMatchNum != undefined)
  40.       {
  41.          gameTimeouts[2] = setTimeout(function()
  42.          {
  43.             eventCover_mc._visible = false;
  44.             doors_mc.gotoAndPlay("open");
  45.             nextMatchNum = -1;
  46.          }
  47.          ,360);
  48.          gameTimeouts[3] = setTimeout(initMatch,200);
  49.       }
  50.       else
  51.       {
  52.          initFinalScreen();
  53.       }
  54.    }
  55.    ,3500);
  56. }
  57. function initMatch()
  58. {
  59.    clearTimeout(gameTimeouts.promtTimeout1);
  60.    joePrompt();
  61.    sounds.stopSound("all");
  62.    sounds["JoePU_BDU_" + match].start();
  63.    setTimeout(function()
  64.    {
  65.       flashHighlight();
  66.    }
  67.    ,1500);
  68.    wears = new Array();
  69.    for(var _loc4_ in ezClick2Drags)
  70.    {
  71.       var _loc1_ = ezClick2Drags[_loc4_];
  72.       _loc1_.targets[0] = {_x:_loc1_._x,_y:_loc1_._y};
  73.       _loc1_.targets[1] = rect_mc;
  74.       _loc1_.targetActions[0] = tweenBack;
  75.       _loc1_.targetActions[1] = hitTarget;
  76.       _loc1_.missedTargetsAction = tweenBack;
  77.       _loc1_.onRollOver = garmentRollOver;
  78.       _loc1_.onRollOut = garmentRollOut;
  79.       _loc1_.onDragStart = startDragging;
  80.       _loc1_.origDepth = _loc1_.getDepth();
  81.       _loc1_.origScale = _loc1_._xscale;
  82.       _loc1_.origRotation = _loc1_._rotation;
  83.       if(!wears[_loc1_.part])
  84.       {
  85.          wears[_loc1_.part] = new Array();
  86.       }
  87.       wears[_loc1_.part][_loc1_.ID] = _loc1_;
  88.    }
  89. }
  90. function startDragging(obj)
  91. {
  92.    _root.sounds.phoo03.start();
  93.    eventCover_mc._visible = true;
  94.    obj._visible = true;
  95.    startRocking(obj,111.6);
  96.    glow.strength = 0;
  97.    obj.filters = [glow];
  98. }
  99. function garmentRollOver()
  100. {
  101.    if(!this.dragging && !EZClick2Drag.DRAGGING)
  102.    {
  103.       _root.sounds.whoosh.start();
  104.       glow.strength = 30;
  105.       this.filters = [glow];
  106.    }
  107. }
  108. function garmentRollOut()
  109. {
  110.    glow.strength = 0;
  111.    this.filters = [glow];
  112. }
  113. function hitTarget(obj)
  114. {
  115.    started = true;
  116.    returnSimilarItems(obj);
  117.    randomEars();
  118.    obj._visible = false;
  119.    magenta.attachClothes(obj.part,obj.ID);
  120.    obj._x = obj.targets[1]._x;
  121.    obj._y = obj.targets[1]._y;
  122.    obj._rotation = 0;
  123.    obj.enabled = false;
  124.    _root.stopGameTimeouts();
  125.    joePrompt();
  126.    sounds.stopSound("all");
  127.    if(obj.ID == match)
  128.    {
  129.       eventCover_mc._visible = true;
  130.       scoreMatch();
  131.       gameTimeouts.posFB1 = setTimeout(function()
  132.       {
  133.          joePosFB[random(joePosFB.length)].start();
  134.       }
  135.       ,1000);
  136.       gameTimeouts.posFB2 = setTimeout(function()
  137.       {
  138.          sounds["JOE_BMMDU_" + match].start();
  139.       }
  140.       ,2100);
  141.       magenta.barkRandom();
  142.       magenta.headReset();
  143.    }
  144.    else
  145.    {
  146.       gameTimeouts[4] = setTimeout(function()
  147.       {
  148.          eventCover_mc._visible = false;
  149.       }
  150.       ,750);
  151.       gameTimeouts.negFB = setTimeout(function()
  152.       {
  153.          joeNegFB[random(joeNegFB.length)].start();
  154.       }
  155.       ,1000);
  156.       magenta.barkRandom(true);
  157.       magenta.headTilt("left");
  158.    }
  159.    _root.sounds.dojoquickturn.start();
  160. }
  161. function snapBack(obj)
  162. {
  163.    this[obj.part + "Wears_mc"][obj.ID + "_mc"].gotoAndStop(1);
  164.    this[obj.part + "Wears_mc"][obj.ID + "_mc"].baseClip_mc._visible = true;
  165.    this[obj.part + "Wears_mc"][obj.ID + "_mc"].useHandCursor = true;
  166.    obj._visible = true;
  167.    obj._xscale = obj.origScale;
  168.    obj._yscale = obj.origScale;
  169.    obj._x = obj.targets[0]._x;
  170.    obj._y = obj.targets[0]._y;
  171.    obj._rotation = obj.origRotation;
  172.    obj.swapDepths(obj.origDepth);
  173.    gameTimeouts[6] = setTimeout(function()
  174.    {
  175.       trace(obj + obj.ID);
  176.       obj.enabled = true;
  177.    }
  178.    ,50);
  179. }
  180. function returnSimilarItems(obj)
  181. {
  182.    for(var _loc2_ in wears[obj.part])
  183.    {
  184.       if(wears[obj.part][_loc2_] != obj)
  185.       {
  186.          snapBack(wears[obj.part][_loc2_]);
  187.       }
  188.    }
  189. }
  190. function tweenBack(obj)
  191. {
  192.    obj._visible = true;
  193.    caurina.transitions.Tweener.addTween(obj,{time:0.5,transition:"easeInSine",_y:obj.targets[0]._y,_xscale:obj.origScale,_yscale:obj.origScale});
  194.    caurina.transitions.Tweener.addTween(obj,{time:0.5,transition:"easeInOutSine",_x:obj.targets[0]._x,_rotation:obj.origRotation,onComplete:function()
  195.    {
  196.       this.swapDepths(this.origDepth);
  197.       eventCover_mc._visible = false;
  198.       eval(this.part + "Wears_mc")[this.ID + "_mc"].gotoAndStop(1);
  199.       eval(this.part + "Wears_mc")[this.ID + "_mc"].baseClip_mc._visible = true;
  200.       eval(this.part + "Wears_mc")[this.ID + "_mc"].baseClip_mc.useHandCursor = true;
  201.    }});
  202. }
  203. function initFinalScreen()
  204. {
  205.    attachMovie("mix_game_reward","mix_game_reward",this.getNextHighestDepth());
  206. }
  207. function flashHighlight()
  208. {
  209.    var _loc1_ = 100;
  210.    setTimeout(function()
  211.    {
  212.       highlightIcon(true);
  213.    }
  214.    ,_loc1_ * 0);
  215.    setTimeout(function()
  216.    {
  217.       highlightIcon(false);
  218.    }
  219.    ,_loc1_ * 1);
  220.    setTimeout(function()
  221.    {
  222.       highlightIcon(true);
  223.    }
  224.    ,_loc1_ * 2);
  225.    setTimeout(function()
  226.    {
  227.       highlightIcon(false);
  228.    }
  229.    ,_loc1_ * 3);
  230.    setTimeout(function()
  231.    {
  232.       highlightIcon(true);
  233.    }
  234.    ,_loc1_ * 4);
  235.    setTimeout(function()
  236.    {
  237.       highlightIcon(false);
  238.    }
  239.    ,_loc1_ * 15);
  240. }
  241. function highlightIcon(highlighted)
  242. {
  243.    magenta.highlightIcon(part,highlighted);
  244. }
  245. function joePrompt()
  246. {
  247.    trace("joePromt");
  248.    if(_root.idle)
  249.    {
  250.       joeIdle[random(joeIdle.length)].start();
  251.    }
  252.    gameTimeouts.promtTimeout1 = setTimeout(joePrompt,random(10000) + 10000);
  253. }
  254. function randomEars()
  255. {
  256.    var _loc1_ = random(3);
  257.    switch(_loc1_)
  258.    {
  259.       case 0:
  260.          magenta.head.ear_l.play();
  261.          break;
  262.       case 1:
  263.          magenta.head.ear_r.play();
  264.          break;
  265.       case 2:
  266.          magenta.head.ear_l.play();
  267.          magenta.head.ear_r.play();
  268.    }
  269. }
  270. stop();
  271. magenta.isIdle = true;
  272. var sounds = new seven2Classes.seven2SND(this,["JOE_BMMDU_010","JOE_BMMDU_011","JOE_BMMDU_012","JOE_BMMDU_013","JOE_BMMDU_014","JOE_BMMDU_015","JOE_BMMDU_016","JOE_BMMDU_008","JOE_BMMDU_car","JOE_BMMDU_chair","JOE_BMMDU_caterpillar","JOE_BMMDU_duck","JOE_BMMDU_bird","JOE_BMMDU_butterfly","JOE_BMMDU_ball","JOE_BMMDU_ladybug","JOE_BMMDU_train","JOE_BMMDU_turtle","JoePU_BDU_car","JoePU_BDU_chair","JoePU_BDU_caterpillar","JoePU_BDU_duck","JoePU_BDU_bird","JoePU_BDU_butterfly","JoePU_BDU_ball","JoePU_BDU_ladybug","JoePU_BDU_train","JoePU_BDU_turtle","JoePU_BDU_78","JoePU_BDU_79","JoePU_BDU_80","JoePU_BDU_81","JoePU_BDU_82","JoePU_BDU_85","done","JOE_BMMDU_006b","JOE_BMMDU_005"]);
  273. var joeIdle = new Array(sounds.JOE_BMMDU_006b,sounds.JOE_BMMDU_005);
  274. sounds.JOE_BMMDU_008.start();
  275. var joePosFB = new Array(sounds.JOE_BMMDU_010,sounds.JOE_BMMDU_011,sounds.JOE_BMMDU_012,sounds.JOE_BMMDU_013,sounds.JOE_BMMDU_014,sounds.JOE_BMMDU_015,sounds.JOE_BMMDU_016);
  276. var joeNegFB = new Array(sounds.JoePU_BDU_78,sounds.JoePU_BDU_79,sounds.JoePU_BDU_80,sounds.JoePU_BDU_81,sounds.JoePU_BDU_82,sounds.JoePU_BDU_85);
  277. var unusedRandoms = new Array();
  278. var i = 0;
  279. while(i < 10)
  280. {
  281.    unusedRandoms.push(i);
  282.    i++;
  283. }
  284. var match;
  285. var part;
  286. var matches = 0;
  287. var wears = new Array();
  288. var nextMatchNum = getUnusedRandom(unusedRandoms);
  289. var glow = new flash.filters.GlowFilter(16777215,1,3,3,30,3);
  290. gameTimeouts[7] = setTimeout(nextMatch,3800);
  291. magenta.debugOn = false;
  292. insideCloset_mc.onRelease = function()
  293. {
  294.    0;
  295.    undefined;
  296. };
  297. insideCloset_mc.useHandCursor = false;
  298.